package com.xiaohe66.web.domain.sys.sec.agg;

import com.xiaohe66.web.domain.account.value.AccountId;
import com.xiaohe66.web.domain.sys.sec.value.SysConfigId;
import com.xiaohe66.web.domain.sys.sec.value.SysConfigKey;
import com.xiaohe66.web.domain.sys.sec.value.SysConfigValue;
import com.xiaohe66.web.integration.domain.Aggregate;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NonNull;
import lombok.ToString;

import java.util.Objects;

/**
 * @author xiaohe
 * @since 2023-12-27 17:41
 */
@Builder
@Getter
@ToString
@AllArgsConstructor
public class SysConfig implements Aggregate<SysConfig, SysConfigId> {

    @NonNull
    private final SysConfigId id;

    @NonNull
    private final AccountId createId;

    @NonNull
    private final SysConfigKey configKey;

    @NonNull
    private SysConfigValue configValue;

    @Override
    public boolean hasSameRootAttribute(SysConfig other) {

        return other != null &&
                Objects.equals(configValue, other.configValue);
    }
}
